import request from './request'
import { LANG } from '@/config/constant'

/**
 * @description 获取活动信息
 * @doc http://yapi.feoffice.lizhi.fm/project/1439/interface/api/34296
 * @param {*} params
 */
export const GET_ACTIVITY_INFO = (params) => request.get('/activity/simple/collect/piece/info', { params })

/**
 * @description 获取当前用户的用户任务信息
 * @doc http://yapi.feoffice.lizhi.fm/project/1439/interface/api/34544
 * @param {*} params
 */
export const GET_MISSION_INFO = ({ activityId, fragment }) =>
  request.get('/activity/simple/collect/piece/task/info', { params: { activityId, fragment } })

/**
 * @description 签到记录
 * @doc http://yapi.feoffice.lizhi.fm/project/1439/interface/api/34544
 * @param {*} params
 */
export const SET_CHECK_IN = (params) => request.get('/activity/simple/collect/piece/task/info', { params })

/**
 * @description 分享记录
 * @doc http://yapi.feoffice.lizhi.fm/project/1439/interface/api/34544
 * @param {*} params
 */
export const SET_SHARE = (params) => request.get('/activity/simple/collect/piece/task/info', { params })

/**
 * @description 获取奖品信息
 * @doc http://yapi.feoffice.lizhi.fm/project/1439/interface/api/34472
 * @param {*} params
 */
export const GET_PRIZE_INFO = (params) => request.get('/activity/simple/collect/piece/prize/list', { params })

/**
 * @description 用户领取额外奖品
 * @doc http://yapi.feoffice.lizhi.fm/project/1439/interface/api/34312
 * @param {*} { itemId = null, activityId } 特殊奖励不传itemId
 */
export const SET_USER_PRIZE = ({ itemId = null, activityId }) =>
  request.post(`/activity/simple/collect/piece/receive/prize`, {}, { params: { itemId, activityId } })

/**
 *@description 用户额外奖品信息
 * @doc http://yapi.feoffice.lizhi.fm/project/1439/interface/api/34584
 * @param {*} { activityId }
 */
export const GET_USER_PRIZE = ({ activityId }) =>
  request.get('/activity/simple/collect/piece/special/prize/info', { params: { activityId } })

/**
 * @description 用户签到动作记录
 * @doc http://yapi.feoffice.lizhi.fm/project/1439/interface/api/31200
 * @param {*} params
 */
export const SET_USER_CHECK_IN = ({ checkInType } = { checkInType: 4 }) =>
  request.get(`/common/checkin/do`, {
    headers: {
      lang: LANG,
    },
    params: {
      checkInType,
    },
  })

/**
 * @description 用户分享动作记录
 * @doc 暂无
 * @param {*} params
 */
export const SET_USER_SHARE = (params) => request.post(`common/activity/finishShare?url=${params.url}`, params)

/**
 * 获取用户碎片信息
 */
export const GET_FRAGMENT_LIST = ({ activityId }) =>
  request.get('/activity/simple/collect/piece/user/piece/info', {
    params: {
      activityId,
    },
  })

/**
 * 获取兑换信息
 */
export const GET_EXCHANGE_INFO = ({ activityId }) =>
  request.get('/activity/simple/collect/piece/exchange/list', {
    params: {
      activityId,
    },
  })

/*
  兑换奖励
*/
export const POST_EXCHANGE_ITEM = ({ activityId, itemId, exchangeType }) =>
  request.post('/activity/simple/collect/piece/exchange', null, {
    params: {
      activityId,
      itemId,
      exchangeType,
    },
  })

/**
 * 获取排行榜信息
 */
export const GET_RANK_LIST = ({ activityId }) =>
  request.get('/activity/simple/collect/piece/rank/list', {
    params: {
      activityId,
    },
  })

/*
  领取奖励
*/
export const POST_RECEIVE_PRICE = ({ activityId, itemId, receiveType = 1 }) =>
  request.post('/activity/simple/collect/piece/receive/prize', null, {
    params: {
      activityId,
      itemId,
      receiveType,
    },
  })

/**
 * 活动扩展信息
 */
export const GET_EXPAND_INFOR = ({ activityId }) =>
  request.get('/activity/simple/collect/piece/expand/info', {
    params: {
      activityId,
    },
  })
